package com.vincent.guava;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;

import org.testng.annotations.Test;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

public class CollectionsTester {
	@Test
	public void collectionsTester() {
		Collection<Integer> targetCollection = null;
		Collections.addAll(targetCollection, 1, 2, 3);

		Collection<Integer> sourceCollection = null;
		Collections.copy((List<Integer>) targetCollection,
				(List<Integer>) sourceCollection);

		Collections.emptyList();
		Collections.emptyIterator();
		Collections.emptyMap();
		Collections.emptySet();

		Collections.replaceAll((List<Integer>) targetCollection, 1, -1);

		targetCollection = Collections.unmodifiableCollection(sourceCollection);

	}

	public void mapsTster() {
		Maps.newHashMap();
		ArrayList<Object> list = Lists.newArrayList();
		Set<Object> set = Sets.newHashSet();
		
		Collections.sort(list, new Comparator<Object>() {

			@Override
			public int compare(Object o1, Object o2) {

				return Objects.hashCode(o1) - Objects.hashCode(o2);
			}
		});
		Objects.toString(set);
	}

	public void ArraysTester() {

		Object[] a = null;
		Arrays.asList(a);

		Arrays.equals(new Object[0], new Object[0]);

		Arrays.toString(a);
	}

}
